//
//  LLLeftSegViewCell.m
//  TaoTuo
//
//  Created by admin on 2019/8/20.
//  Copyright © 2019 admin. All rights reserved.
//

#import "LLLeftSegViewCell.h"

@interface LLLeftSegViewCell ()

@property (nonatomic, strong) UIView *normalView;
@property (nonatomic, strong) UILabel *normalLabel;

@property (nonatomic, strong) UIView *selectedView;
@property (nonatomic, strong) UILabel *selectedLabel;
@property (nonatomic, strong) UIImageView *selectedImgView;

@end

@implementation LLLeftSegViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self setupSubviews];
        
    }
    return self;
}

- (void)setTitle:(NSString *)title
{
    _title = title;
    self.normalLabel.text = title;
    self.selectedLabel.text = title;
}

- (void)setupSubviews
{
    [self.normalView addSubview:self.normalLabel];
    
    [self.selectedView addSubview:self.selectedImgView];
    [self.selectedView addSubview:self.selectedLabel];
    
    
    self.backgroundView = self.normalView;
    self.selectedBackgroundView = self.selectedView;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    self.normalView.frame = self.contentView.bounds;
    self.selectedView.frame = self.contentView.bounds;
    
    self.normalLabel.frame = self.normalView.bounds;
    self.selectedLabel.frame = self.selectedView.bounds;
    
    self.selectedImgView.frame = CGRectMake(5, 10, 2, self.height - 20);
    
    
}

- (UIView *)normalView
{
    if (!_normalView) {
        _normalView = [[UIView alloc] init];
        _normalView.backgroundColor = kSeparatorColor;
    }
    return _normalView;
}

- (UILabel *)normalLabel
{
    if (!_normalLabel) {
        _normalLabel = [UILabel labelTextCenterWithTitle:@"" color:UIColorHex(000000) fontSize:15];
    }
    return _normalLabel;
}


- (UIView *)selectedView
{
    if (!_selectedView) {
        _selectedView = [[UIView alloc] init];
        _selectedView.backgroundColor = [UIColor whiteColor];
    }
    return _selectedView;
}

- (UIImageView *)selectedImgView
{
    if (!_selectedImgView) {
        _selectedImgView = [[UIImageView alloc] init];
        _selectedImgView.backgroundColor = kMainColor;
    }
    return _selectedImgView;
}

- (UILabel *)selectedLabel
{
    if (!_selectedLabel) {
        _selectedLabel = [UILabel labelTextCenterWithTitle:@"" color:kMainColor fontSize:15];
    }
    return _selectedLabel;
}


@end
